package com.pavlinic.mylisp.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class IOUtils {
	private static final String LINE_SEPARATOR = System.getProperty("line.separator");

	public static String readAll(InputStream stream) throws IOException {
		final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(stream));
		final StringBuilder builder = new StringBuilder();

		String line;
		while ((line = bufferedReader.readLine()) != null) {
			builder.append(line).append(LINE_SEPARATOR);
		}

		return builder.toString();
	}

}
